//
//  RSWebView+Proxy.m
//  StaffTax
//
//  Created by 侯伟 on 2020/3/13.
//  Copyright © 2020 侯伟. All rights reserved.
//

#import "RSWebView+Proxy.h"

@implementation RSWebView (Proxy)

- (BOOL)canGoBack{
    return self.webView.canGoBack;
}

- (BOOL)canGoForward{
    return self.webView.canGoForward;
}

- (BOOL)isLoading{
    return self.webView.isLoading;
}

- (NSString*)title{
    return self.webView.title;
}

- (NSURL*)url{
    return self.webView.URL;
}

- (WKNavigation*)reload{
    return [self.webView reload];
}

- (WKNavigation*)reloadFromOrigin{
    return [self.webView reloadFromOrigin];
}

- (WKNavigation* _Nullable)loadURLString:(NSString*)urlString{
    if(!urlString.length) return NULL;
    
    self.progressViewHidden = NO;
    
    return [self loadURL:[NSURL URLWithString:urlString]];
}

- (WKNavigation* _Nullable)loadURL:(NSURL *)url{
    
    if(!url) return NULL;
    
    self.progressViewHidden = NO;
    
    NSURLRequest* request = [NSURLRequest requestWithURL:url];
    
    return [self.webView loadRequest:request];
}

- (WKNavigation*)loadHTMLString:(NSString*)htmlString baseURL:(NSURL*)baseURL{
    
    return [self.webView loadHTMLString:htmlString baseURL:baseURL];
}

- (nullable WKNavigation *)goBack{
    return [self.webView goBack];
}

- (nullable WKNavigation *)goForward{
    return [self.webView goForward];
}


- (void)stopLoading{
    [self.webView stopLoading];
}

- (void)evaluateJavaScript:(NSString*)javaScriptString completionHandler:(void(^)(id,NSError*))completionHandler{
    [self.webView evaluateJavaScript:javaScriptString completionHandler:completionHandler];
}

@end
